﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:ui="clr-namespace:Bookvar.UI;assembly=Bookvar.UI">

    <DrawingBrush x:Key="GreenTopic" Viewbox="0,0,161.149,90" ViewboxUnits="Absolute">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup>
                    <GeometryDrawing>
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush EndPoint="0.541,-0.196" StartPoint="0.54,1.612">
                                <GradientStop Color="#FF34AF00" Offset="0.75"/>
                                <GradientStop Color="#FF154700" Offset="0.279"/>
                                <GradientStop Color="#FF278300" Offset="0.49"/>
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0,0,161,90"/>
                        </GeometryDrawing.Geometry>
                    </GeometryDrawing>
                    <DrawingGroup>
                        <DrawingGroup.Transform>
                            <MatrixTransform Matrix="1,0,0,1,0.0830000000000142,-0.233"/>
                        </DrawingGroup.Transform>
                        <GeometryDrawing Geometry="M0.44896806,40.151998 C0.44896806,40.151998 42.431998,25.392804 93.948459,22.730669 121.282,21.318198 137.63763,21.285 142.28188,21.651545 148.61528,22.151407 160.78193,24.151473 160.78193,24.151473 160.78193,24.151473 162.2822,6.8190384 157.78195,2.8185308 152.28233,-1.5143989 149.11565,0.48514396 136.28173,0.31673443 131.11564,0.81872834 21.615838,-0.18182614 8.6155224,0.48566225 -2.8846556,-1.0143332 0.44896806,40.151998 0.44896806,40.151998 z">
                            <GeometryDrawing.Brush>
                                <LinearGradientBrush EndPoint="0.428,-1.027" StartPoint="0.484,1.297">
                                    <GradientStop Color="#FF278300" Offset="0"/>
                                    <GradientStop Color="#007CD818" Offset="0.622"/>
                                    <GradientStop Color="#FF278300" Offset="0.274"/>
                                </LinearGradientBrush>
                            </GeometryDrawing.Brush>
                        </GeometryDrawing>
                    </DrawingGroup>
                </DrawingGroup>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <DrawingBrush x:Key="BlueTopic" Viewbox="0,0,161.149,90" ViewboxUnits="Absolute">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <GeometryDrawing>
                    <GeometryDrawing.Brush>
                        <LinearGradientBrush EndPoint="0.541,-0.196" StartPoint="0.54,1.612">
                            <GradientStop Color="#FF008BAA" Offset="0.75"/>
                            <GradientStop Color="#FF014B5A" Offset="0.279"/>
                            <GradientStop Color="#FF014B5A" Offset="0.49"/>
                        </LinearGradientBrush>
                    </GeometryDrawing.Brush>
                    <GeometryDrawing.Geometry>
                        <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0,0,161,90"/>
                    </GeometryDrawing.Geometry>
                </GeometryDrawing>
                <DrawingGroup>
                    <DrawingGroup.Transform>
                        <MatrixTransform Matrix="1,0,0,1,0.0830000000000142,-0.233"/>
                    </DrawingGroup.Transform>
                    <GeometryDrawing Geometry="M-6.2793463E-06,38.397003 C1.5003355,37.865914 42.568509,25.326653 93.916052,21.052509 117.58334,19.082455 139.41679,20.940868 139.41679,20.940868 139.41679,20.940868 160.833,22.666629 160.833,22.666629 160.833,22.666629 162.75065,7.7328426 158.25074,3.8166965 154.75027,-2.9530789 145.50017,2.0246213 130.91634,0.22531691 126.71616,-0.29288731 18.832222,0.16567292 7.2497807,0.76387346 -2.1666133,3.2197496 1.4183049,15.166954 -6.2793463E-06,38.397003 z">
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush EndPoint="0.428,-1.027" StartPoint="0.484,1.297">
                                <GradientStop Color="#FF008BAA" Offset="0"/>
                                <GradientStop Color="#00008BAA" Offset="0.622"/>
                                <GradientStop Color="#7F014B5A" Offset="0.274"/>
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                </DrawingGroup>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <DrawingBrush x:Key="BlueTopicTextBox" Viewbox="0,0,126,72" ViewboxUnits="Absolute">
        <DrawingBrush.Drawing>
            <GeometryDrawing Brush="#FF014B5A">
                <GeometryDrawing.Geometry>
                    <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0,0,126,72"/>
                </GeometryDrawing.Geometry>
            </GeometryDrawing>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <DrawingBrush x:Key="MindMapBackgroud" Viewbox="0,0,123,72" ViewboxUnits="Absolute">
        <DrawingBrush.Drawing>
            <GeometryDrawing Brush="#FF183D01">
                <GeometryDrawing.Geometry>
                    <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0,0,123,72"/>
                </GeometryDrawing.Geometry>
            </GeometryDrawing>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <DrawingBrush x:Key="OrangeTopic" Viewbox="0,0,161.149,90" ViewboxUnits="Absolute">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <GeometryDrawing>
                    <GeometryDrawing.Brush>
                        <LinearGradientBrush EndPoint="0.541,-0.196" StartPoint="0.54,1.612">
                            <GradientStop Color="#FFC5AD02" Offset="0.568"/>
                            <GradientStop Color="#FFB97B04" Offset="0.151"/>
                            <GradientStop Color="#FFB97B04" Offset="0.402"/>
                        </LinearGradientBrush>
                    </GeometryDrawing.Brush>
                    <GeometryDrawing.Geometry>
                        <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0,0,161,90"/>
                    </GeometryDrawing.Geometry>
                </GeometryDrawing>
                <DrawingGroup>
                    <DrawingGroup.Transform>
                        <MatrixTransform Matrix="1,0,0,1,-0.382,-1.483"/>
                    </DrawingGroup.Transform>
                    <GeometryDrawing Geometry="M1.0491495,39.447998 C1.0491495,39.447998 42.807394,24.103448 94.382024,22.302481 120.38227,21.394563 140.38219,22.191034 140.38219,22.191034 140.38219,22.191034 160.38198,23.904283 160.38198,23.904283 160.38198,23.904283 172.3821,-7.0128426 131.382,1.4748381 92.382025,1.4748381 25.382535,0.67364162 10.383174,7.0820586 -4.6161872,13.490476 1.0491495,39.447998 1.0491495,39.447998 z">
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush EndPoint="0.487,0.105" StartPoint="0.494,0.456">
                                <GradientStop Color="#FFCA8700" Offset="0"/>
                                <GradientStop Color="#00CA8700" Offset="0.999"/>
                                <GradientStop Color="#7FCA8700" Offset="0.48"/>
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                </DrawingGroup>
                <DrawingGroup>
                    <DrawingGroup.Transform>
                        <MatrixTransform Matrix="1,0,0,1,-5.15,-3.212"/>
                    </DrawingGroup.Transform>
                    <GeometryDrawing>
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0.5,0.5,170.483,94.86"/>
                        </GeometryDrawing.Geometry>
                        <GeometryDrawing.Pen>
                            <Pen DashCap="Flat" EndLineCap="Flat" LineJoin="Miter" MiterLimit="1" StartLineCap="Flat" Thickness="1">
                                <Pen.Brush>
                                    <LinearGradientBrush EndPoint="0.503,-0.212" StartPoint="0.497,1.212">
                                        <GradientStop Color="#FF4F6073" Offset="0.715"/>
                                        <GradientStop Color="#FF93AFCF" Offset="0"/>
                                        <GradientStop Color="#FF4F6073" Offset="0.961"/>
                                        <GradientStop Color="#FF90ACCC" Offset="0.343"/>
                                    </LinearGradientBrush>
                                </Pen.Brush>
                            </Pen>
                        </GeometryDrawing.Pen>
                    </GeometryDrawing>
                </DrawingGroup>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <DrawingBrush x:Key="OrangeTopicTextBox" Viewbox="0,0,126,72" ViewboxUnits="Absolute">
        <DrawingBrush.Drawing>
            <GeometryDrawing Brush="#FFA36800">
                <GeometryDrawing.Geometry>
                    <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0,0,126,72"/>
                </GeometryDrawing.Geometry>
            </GeometryDrawing>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <DrawingBrush x:Key="GreenTopicTextBox" Viewbox="0,0,123,72" ViewboxUnits="Absolute">
        <DrawingBrush.Drawing>
            <GeometryDrawing Brush="#FF183D01">
                <GeometryDrawing.Geometry>
                    <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0,0,123,72"/>
                </GeometryDrawing.Geometry>
            </GeometryDrawing>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <Style x:Key="NameTextBox" TargetType="{x:Type TextBox}">
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Padding" Value="8" />
        <Setter Property="Background" Value="{StaticResource BlueTopicTextBox}" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="SpellCheck.IsEnabled" Value="True" />
        <Setter Property="Typography.NumeralStyle" Value="OldStyle" />
        <Setter Property="BorderThickness" Value="0,0,0,0"/>
        <Setter Property="Margin" Value="0,0,0,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBoxBase">
                    <Border Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}" SnapsToDevicePixels="True">
                        <ScrollViewer Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderBrush" Value="{DynamicResource BlueTopicTextBox}"/>
    </Style>

    <Style x:Key="NameTextBoxLevel1" TargetType="{x:Type TextBox}">
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Padding" Value="10" />
        <Setter Property="Background" Value="{StaticResource GreenTopicTextBox}" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="SpellCheck.IsEnabled" Value="True" />
        <Setter Property="Typography.NumeralStyle" Value="OldStyle" />
        <Setter Property="BorderThickness" Value="0,0,0,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBoxBase">
                    <Border Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}" SnapsToDevicePixels="True">
                        <ScrollViewer Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="Border" TargetType="{x:Type Border}">
        <Setter Property="BorderBrush" Value="{StaticResource BlueTopic}" />
        <Setter Property="BorderThickness" Value="2,20,2,2" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="CornerRadius" Value="4" />
    </Style>

    <Style x:Key="BorderStackPanel" TargetType="{x:Type StackPanel}">
        <Setter Property="Background" Value="{StaticResource BlueTopic}" />

    </Style>

    <Style x:Key="MainBorderStackPanel" TargetType="{x:Type StackPanel}">
        <Setter Property="Background" Value="{StaticResource OrangeTopic}" />

    </Style>

    <Style x:Key="SelectedBorder" TargetType="{x:Type Border}">
        <Setter Property="BorderBrush" Value="{StaticResource BlueTopic}" />
        <Setter Property="BorderThickness" Value="2,20,2,2" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="CornerRadius" Value="4" />
    </Style>

    <Style x:Key="BorderLevel1" TargetType="{x:Type Border}">
        <Setter Property="BorderBrush" Value="{StaticResource GreenTopic}" />
        <Setter Property="BorderThickness" Value="4,20,4,4" />

        <Setter Property="CornerRadius" Value="6,6,6,6" />
    </Style>

    <Style x:Key="BorderLevel1StackPanel" TargetType="{x:Type StackPanel}">
        <Setter Property="Background" Value="{StaticResource GreenTopic}" />

    </Style>

    <Style x:Key="SelectedBorderLevel1" TargetType="{x:Type Border}">
        <Setter Property="BorderBrush" Value="{StaticResource GreenTopic}" />
        <Setter Property="BorderThickness" Value="4,20,4,4" />

        <Setter Property="CornerRadius" Value="6,6,6,6" />
    </Style>

    <Style x:Key="SelectedTopicBorder" TargetType="{x:Type Border}">
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CornerRadius" Value="2" />
        <Setter Property="Padding" Value="2" />
    </Style>

    <Style x:Key="HoverTopicBorder" TargetType="{x:Type Border}">
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="CornerRadius" Value="2" />
        <Setter Property="Padding" Value="2" />
    </Style>

    <Style TargetType="{x:Type ui:ResourceItemsControl}">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"
								 VerticalAlignment="Center"
								 HorizontalAlignment="Center"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Storyboard x:Key="StoryboardTopicMouseEnter">
        <ThicknessAnimation Duration="0:0:0" Storyboard.TargetName="header" Storyboard.TargetProperty="(Border.BorderThickness)" To="1"/>
    </Storyboard>

    <Storyboard x:Key="StoryboardTopicMouseLeave">
        <ThicknessAnimation Duration="0:0:0" Storyboard.TargetName="header" Storyboard.TargetProperty="(Border.BorderThickness)" To="0"/>
    </Storyboard>

    <ControlTemplate x:Key="toggleChildrenCheckBox" TargetType="{x:Type CheckBox}">
        <Grid Width="200" Height="200" >
            <Grid.LayoutTransform>
                <ScaleTransform ScaleX="0.07" ScaleY="0.07" />
            </Grid.LayoutTransform>
            <Ellipse Stroke="#FF000000" HorizontalAlignment="Stretch" Width="Auto" StrokeThickness="10">
                <Ellipse.Fill>
                    <RadialGradientBrush GradientOrigin="0.442,0.581">
                        <RadialGradientBrush.RelativeTransform>
                            <TransformGroup>
                                <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="0.887" ScaleY="0.807"/>
                                <SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.5"/>
                                <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5"/>
                                <TranslateTransform X="-0.09" Y="-0.21"/>
                            </TransformGroup>
                        </RadialGradientBrush.RelativeTransform>
                        <GradientStop Color="#FF8AA1BB" Offset="0.16"/>
                        <GradientStop Color="#FF4F6073" Offset="0.931"/>
                    </RadialGradientBrush>
                </Ellipse.Fill>
            </Ellipse>
            <Rectangle Name="rect1" Fill="#FF4F6073" Margin="82.86,33.88,97.14,46.12" Height="Auto" Width="20"/>
            <Rectangle Fill="#FF4F6073" Margin="31.592,83.518,48.408,96.482" Width="Auto" Height="20"/>

            <Rectangle Name="rect" Fill="#FF000000" Margin="90,40,90,40" Height="Auto" Width="20"/>
            <Rectangle Fill="#FF000000" Margin="40,90,40,90" Width="Auto" Height="20"/>
        </Grid>
        <!--
<Grid Width="200" Height="200">
               <Ellipse Stroke="#FF445467" StrokeMiterLimit="1.000000" StrokeThickness="1" Margin="-1,-1,-1.5,-1.5">
                    <Ellipse.Fill>
                         <RadialGradientBrush GradientOrigin="0.442,0.581">
                              <RadialGradientBrush.RelativeTransform>
                                   <TransformGroup>
                                        <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="0.887" ScaleY="0.807"/>
                                        <SkewTransform AngleX="0" AngleY="0" CenterX="0.5" CenterY="0.5"/>
                                        <RotateTransform Angle="0" CenterX="0.5" CenterY="0.5"/>
                                        <TranslateTransform X="-0.09" Y="-0.21"/>
                                   </TransformGroup>
                              </RadialGradientBrush.RelativeTransform>
                              <GradientStop Color="#FF8AA1BB" Offset="0.16"/>
                              <GradientStop Color="#FF4F6073" Offset="0.931"/>
                         </RadialGradientBrush>
                    </Ellipse.Fill>
               </Ellipse>
               <Rectangle Fill="#FF4F6073" Stroke="#FF000000" StrokeMiterLimit="1.000000" StrokeThickness="0" Margin="8,87.29,25.417,75.907"/>
               <Rectangle x:Name="rect1" Fill="#FF4F6073" Stroke="#FF000000" StrokeMiterLimit="1.000000" StrokeThickness="0" RenderTransformOrigin="0.5,0.5" Margin="78.405,26.135,89.377,4.907"/>
               <Rectangle Name="rect" Stroke="#FF000000" StrokeMiterLimit="1.000000" StrokeThickness="0" Fill="#FFCA8700" RenderTransformOrigin="0.5,0.5" Margin="83.405,31.135,85.377,21.907"/>
               <Rectangle Fill="#FFCA8700" Stroke="#FF000000" StrokeMiterLimit="1.000000" StrokeThickness="0" Margin="22,91.64,25.417,81.907" VerticalAlignment="Stretch" Height="Auto"/>
          </Grid>
-->

        <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="False">
                <Setter TargetName="rect"
						Property="Visibility"
						Value="Hidden" />
                <Setter TargetName="rect1"
						Property="Visibility"
						Value="Hidden" />
            </Trigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <DataTemplate x:Key="mainTopicTemplate" >

        <StackPanel x:Name="holder" Orientation="Horizontal">
            <Border x:Name="header" Style="{StaticResource HoverTopicBorder}">
                <StackPanel Orientation="Horizontal"  Margin="0,0,0,0" Style="{StaticResource MainBorderStackPanel}" >
                    <Border BorderThickness="5,24,5,5" Padding="1" Margin="0" CornerRadius="7">
                        <StackPanel Orientation="Vertical">
                            <TextBox x:Name="PART_TopicName" FontSize="32" Padding="15" Background="{StaticResource OrangeTopicTextBox}"
							 SpellCheck.IsEnabled="True" Typography.NumeralStyle="OldStyle" Text="" BorderThickness="0" />
                            <ui:ResourceItemsControl x:Name="PART_Resources"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Border>
        </StackPanel>
        <DataTemplate.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="holder">
                <BeginStoryboard Storyboard="{StaticResource StoryboardTopicMouseEnter}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="holder">
                <BeginStoryboard Storyboard="{StaticResource StoryboardTopicMouseLeave}"/>
            </EventTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="topicTemplate" >
        <StackPanel x:Name="holder" Orientation="Horizontal" >
            <Border x:Name="header" Style="{StaticResource HoverTopicBorder}" CornerRadius="2,2,2,2">
                <StackPanel Orientation="Horizontal"  Margin="0,0,0,0" Style="{StaticResource BorderStackPanel}" >
                    <Border Style="{StaticResource Border}" Padding="0,0,0,0" BorderThickness="4,20,4,4">
                        <StackPanel Orientation="Vertical" >
                            <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBox}" />
                            <ui:ResourceItemsControl x:Name="PART_Resources"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Border>
            <CheckBox x:Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />
        </StackPanel>
        <DataTemplate.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="holder">
                <BeginStoryboard Storyboard="{StaticResource StoryboardTopicMouseEnter}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="holder">
                <BeginStoryboard Storyboard="{StaticResource StoryboardTopicMouseLeave}"/>
            </EventTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="selectedTopicTemplate" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <Border x:Name="header" Style="{StaticResource SelectedTopicBorder}">
                <StackPanel Orientation="Horizontal"  Margin="0,0,0,0" Style="{StaticResource BorderStackPanel}" >
                    <Border Style="{StaticResource SelectedBorder}" BorderThickness="4,20,4,4" Padding="0,0,0,0">
                        <StackPanel Orientation="Vertical">
                            <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBox}" />
                            <ui:ResourceItemsControl x:Name="PART_Resources"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Border>
            <CheckBox Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />
        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="leftTopicTemplate" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <CheckBox x:Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />

            <Border x:Name="header" Style="{StaticResource HoverTopicBorder}">
                <StackPanel Orientation="Horizontal"  Margin="0,0,0,0" Style="{StaticResource BorderStackPanel}" >
                    <Border Style="{StaticResource Border}" BorderThickness="4,20,4,4" Padding="0,0,0,0">
                        <StackPanel Orientation="Vertical">
                            <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBox}" />
                            <ui:ResourceItemsControl x:Name="PART_Resources"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Border>
        </StackPanel>
        <DataTemplate.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="holder">
                <BeginStoryboard Storyboard="{StaticResource StoryboardTopicMouseEnter}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="holder">
                <BeginStoryboard Storyboard="{StaticResource StoryboardTopicMouseLeave}"/>
            </EventTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="leftSelectedTopicTemplate" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <CheckBox Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />

            <Border x:Name="header" Style="{StaticResource SelectedTopicBorder}">
                <StackPanel Orientation="Horizontal"  Margin="0,0,0,0" Style="{StaticResource BorderStackPanel}" >
                    <Border Style="{StaticResource SelectedBorder}" BorderThickness="4,20,4,4" Padding="0,0,0,0">
                        <StackPanel Orientation="Vertical">
                            <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBox}" />
                            <ui:ResourceItemsControl x:Name="PART_Resources"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Border>

        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="topicTemplateLevel1" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <Border x:Name="header" Style="{StaticResource HoverTopicBorder}">
                <StackPanel Orientation="Horizontal"  Margin="0,0,0,0" Style="{StaticResource BorderLevel1StackPanel}" >
                    <Border Style="{StaticResource BorderLevel1}" BorderThickness="4,20,4,4" Padding="0,0,0,0">
                        <StackPanel Orientation="Vertical">
                            <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBoxLevel1}" />
                            <ui:ResourceItemsControl x:Name="PART_Resources"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Border>
            <CheckBox x:Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />
        </StackPanel>
        <DataTemplate.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="holder">
                <BeginStoryboard Storyboard="{StaticResource StoryboardTopicMouseEnter}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="holder">
                <BeginStoryboard Storyboard="{StaticResource StoryboardTopicMouseLeave}"/>
            </EventTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="selectedTopicTemplateLevel1" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <Border x:Name="header" Style="{StaticResource SelectedTopicBorder}">
                <StackPanel Orientation="Horizontal"  Margin="0,0,0,0" Style="{StaticResource BorderLevel1StackPanel}" >
                    <Border Style="{StaticResource SelectedBorderLevel1}" BorderThickness="4,20,4,4" Padding="0,0,0,0">
                        <StackPanel Orientation="Vertical">
                            <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBoxLevel1}" />
                            <ui:ResourceItemsControl x:Name="PART_Resources"/>
                        </StackPanel>

                    </Border>
                </StackPanel>
            </Border>
            <CheckBox Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />
        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="leftTopicTemplateLevel1" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <CheckBox x:Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />
            <Border x:Name="header" Style="{StaticResource HoverTopicBorder}">
                <StackPanel Orientation="Horizontal" Margin="0,0,0,0" Style="{StaticResource BorderLevel1StackPanel}" >
                    <Border Style="{StaticResource BorderLevel1}" BorderThickness="4,20,4,4" Padding="0,0,0,0">
                        <StackPanel Orientation="Vertical">
                            <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBoxLevel1}" />
                            <ui:ResourceItemsControl x:Name="PART_Resources"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Border>
        </StackPanel>
        <DataTemplate.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="holder">
                <BeginStoryboard Storyboard="{StaticResource StoryboardTopicMouseEnter}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="holder">
                <BeginStoryboard Storyboard="{StaticResource StoryboardTopicMouseLeave}"/>
            </EventTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <DataTemplate x:Key="leftSelectedTopicTemplateLevel1" >
        <StackPanel x:Name="holder" Orientation="Horizontal">
            <CheckBox Name="PART_ChildrenToggle" Template="{DynamicResource toggleChildrenCheckBox}" Height="15" Width="15" />

            <Border x:Name="header" Style="{StaticResource SelectedTopicBorder}">
                <StackPanel Orientation="Horizontal"  Margin="0,0,0,0" Style="{StaticResource BorderLevel1StackPanel}" >

                    <Border Style="{StaticResource SelectedBorderLevel1}"  BorderThickness="4,20,4,4" Padding="0,0,0,0">
                        <StackPanel Orientation="Vertical">
                            <TextBox x:Name="PART_TopicName" Style="{DynamicResource NameTextBoxLevel1}" />
                            <ui:ResourceItemsControl x:Name="PART_Resources"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Border>

        </StackPanel>
    </DataTemplate>

</ResourceDictionary>